﻿using WeiXin.Base.Pay.Lib;

namespace WeiXin.Base.Pay
{
    public class DownloadBill
    {
        /// <summary>
        /// 下载对账单
        /// </summary>
        /// <param name="bill_date"> 下载对账单的日期（格式：20140603，一次只能下载一天的对账单）</param>
        /// <param name="bill_type">账单类型
        ///         ALL，返回当日所有订单信息，默认值
        ///         SUCCESS，返回当日成功支付的订单
        ///         REFUND，返回当日退款订单
        ///         REVOKED，已撤销的订单</param>
        /// <returns>对账单结果（xml格式）</returns>
        public static WxPayData Run(string bill_date, string bill_type)
        {
            #region 下载对账单
            WxPayLog.Info("DownloadBill", "DownloadBill is processing...");

            WxPayData data = new WxPayData();
            data.SetValue("bill_date", bill_date);//账单日期
            data.SetValue("bill_type", bill_type);//账单类型
            WxPayData result = WxPayApi.DownloadBill(data);//提交下载对账单请求给API，接收返回结果

            WxPayLog.Info("DownloadBill", "DownloadBill process complete, result : " + result.ToXml());
            return result; 
            #endregion
        }
    }
}